package com.d.ui.view.sort;

import com.d.lib.ui.view.LogUtil;
import com.d.lib.ui.view.flowlayout.CommonHolder;
import com.d.lib.ui.view.sort.SortBean;
import com.d.lib.ui.view.sort.SortLibAdapter;
import com.d.ui.view.ResourceTable;
import java.util.List;
import ohos.agp.components.Component;
import ohos.agp.utils.TextTool;
import ohos.app.Context;


public class SortAdapter extends SortLibAdapter<SortBean> {

  private String index = "";

  SortAdapter(Context context, List<SortBean> datas, int layoutId) {
    super(context, datas, layoutId);
  }

  @Override
  public void convert(int position, CommonHolder holder, SortBean item) {

    LogUtil.debug("sort",
        " item: " + item + ", item.isLetter: " + item.isLetter);
    if (item.isLetter) {
      holder.setVisibility(ResourceTable.Id_llyt_sort, Component.VISIBLE);
      holder.setText(ResourceTable.Id_tv_letter, item.letter);
    } else {
      if (TextTool.isEqual("00444", item.content) || TextTool.isEqual("#蔡依林", item.content)) {
        holder.setVisibility(ResourceTable.Id_llyt_sort, Component.VISIBLE);
        holder.setText(ResourceTable.Id_tv_letter, item.letter);
      } else {
        holder.setVisibility(ResourceTable.Id_llyt_sort, Component.HIDE);
      }
    }
    index = item.getIndex();
    holder.setText(ResourceTable.Id_tv_content, item.content);
  }

}
